#define _CRT_SECURE_NO_WARNINGS
#include"danlianbiao.h"
void dayin(y* t) {
	if (t == NULL) {
		printf("NULL");
	}
    else {
		while (t != NULL) {
			printf("%d", t->data);
			t = t->next;
		}
     }
}
y* shengqingkongjian(x a) {
	y* new = (y*)malloc(sizeof(y));
	new->data = a;
	new->next = NULL;
	return new;
}
void toucha(y** tt, x a) {
	y* new= shengqingkongjian(a);
	new->next = *tt;
	*tt = new;
}
void weicha(y** tt, x a) {
	y* new = shengqingkongjian(a);
	if (*tt == NULL) {
		*tt = new;
	}
	
	else {
		y* l = *tt;
		while (l->next) {
			l = l->next;
		}
		l->next = new;
	}
}
void toushan(y** tt) {
		y* l = (*tt)->next;
		free(*tt);
		*tt = l;
}
void weishan(y** tt) {
	if (*tt == NULL) {
		return;
	}
	else if ((*tt)->next==NULL) {
		free(*tt);
		*tt = NULL;
	}
	else {
		y* p = NULL;
		y* l = *tt;
		while (l->next != NULL) {
			p = l;
			l = l->next;
		}
		p->next = NULL;
		free(l);
	}
}
y* chaxun(y* t, x a) {
	y* new =t;
	while (new->data != a) {
		if (new->next == NULL) {
			return NULL;
		}
		else {
        new = new->next;
		}
		
	}
	return new;
}
void zaiAqianmiancharuRON(y** tt, y* ron, x a) {
	if (ron == *tt) {
		toucha(tt, a);
	}
	else {
    y* new = shengqingkongjian(a);
	y* w = *tt;
	while (w->next != ron) {
		w = w->next;
	}
	w->next = new;
	new->next = ron;
	}
	
}
void shanchuA(y** tt, y* ron) {
	if (*tt == ron) {
		toushan(*tt);
	}
	else {
    y* new = *tt;
	while (new->next != ron) {
		new = new->next;
	}
	new->next = ron->next;
	ron->next = NULL;
	free(ron);
	}
	
}